<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<?php
    session_start();
    if(isset($_POST['submit'])){
            include("includes/dbcon.php");
            $username = $_POST['username'];
            $pass = $_POST['password'];
            $salt= substr($username , 0 , 2);
            $enc_pass = crypt($pass ,$salt);
            $query = "SELECT * FROM users WHERE username = '{$username}' AND password ='{$enc_pass}'";
            $queryset = mysql_query($query,$con); 
            while($query_row=mysql_fetch_array($queryset)){
                $_SESSION['uname'] = $query_row['username'];
                $_SESSION['password'] = $query_row['password'];
            }  
            
        }
    if(isset($_SESSION['uname']) && $_SESSION['password']){
        header("location:home.php");
    
    }
?>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<meta name="author" content="FreeUser" />

	<title>Sign in | Drafts Store</title>
</head>

<body>
 <script src="//connect.facebook.net/en_US/all.js"></script>
    <script type="text/javascript">
    FB.init("225020457568403","includes/xd_receiver.htm"); 
    </script>
 <form action="index.html" method="post">
<label for="username">Username <input type="text" name="uname"/></label><br/>
<label for="password">Password <input type="password" name="password"/></label><br/>
<label for="facebook_signIn">
<div id="fb-root"></div>
<script>
 window.fbAsyncInit = function() {
    FB.init({
      appId      : '225020457568403', 
      channelUrl : '//localhost/xd_receiver.htm', 
      status     : true, 
      cookie     : true, 
      oauth      : true, 
      xfbml      : true  
    });
  };
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=225020457568403";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-login-button" data-show-faces="false" data-width="200" data-max-rows="1"></div>
</label><br/>
<label for="twitter_signIn">Sign in with twitter</label><br/>
 <input type="submit" value="Sign in !"/>
</form>
</body>
</html>